package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Orde;
import com.ruoyi.system.service.IOrdeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单管理Controller
 * 
 * @author ruoyi
 * @date 2024-12-10
 */
@RestController
@RequestMapping("/system/orde")
public class OrdeController extends BaseController
{
    @Autowired
    private IOrdeService ordeService;

    /**
     * 查询订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:orde:list')")
    @GetMapping("/list")
    public TableDataInfo list(Orde orde)
    {
        startPage();
        List<Orde> list = ordeService.selectOrdeList(orde);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:orde:list2')")
    @GetMapping("/list2")
    public TableDataInfo list2(Orde orde)
    {
        startPage();
        List<Orde> list = ordeService.selectOrdeList2(orde);
        System.out.println(list);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:orde:list3')")
    @GetMapping("/list3")
    public TableDataInfo list3(Orde orde)
    {
        startPage();
        List<Orde> list = ordeService.selectOrdeList3(orde);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:orde:list4')")
    @GetMapping("/list4")
    public TableDataInfo list4(Orde orde)
    {
        startPage();
        List<Orde> list = ordeService.selectOrdeList4(orde);
        return getDataTable(list);
    }

    /**
     * 导出订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:orde:export')")
    @Log(title = "订单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Orde orde)
    {
        List<Orde> list = ordeService.selectOrdeList(orde);
        ExcelUtil<Orde> util = new ExcelUtil<Orde>(Orde.class);
        util.exportExcel(response, list, "订单管理数据");
    }

    /**
     * 获取订单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orde:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(ordeService.selectOrdeByRecordId(recordId));
    }

    /**
     * 新增订单管理
     */
    @PreAuthorize("@ss.hasPermi('system:orde:add')")
    @Log(title = "订单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Orde orde)
    {
        return toAjax(ordeService.insertOrde(orde));
    }

    /**
     * 修改订单管理
     */
    @PreAuthorize("@ss.hasPermi('system:orde:edit')")
    @Log(title = "订单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Orde orde)
    {
        System.out.println(orde);
        return toAjax(ordeService.updateOrde(orde));
    }

    /**
     * 删除订单管理
     */
    @PreAuthorize("@ss.hasPermi('system:orde:remove')")
    @Log(title = "订单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(ordeService.deleteOrdeByRecordIds(recordIds));
    }
}
